package com.linghu.tankgame;

import java.io.BufferedWriter;
import java.io.FileWriter;
import java.io.IOException;

/**
 * @author 令狐荣豪
 * @version 1.0
 * 该类用于记录相关信息，和文件交互，IO
 */
public class Recoder {
    //定义变量，记录我方击毁敌方坦克数量
    private static int allEnemyTankNum=0;
    //定义IO对象,用于写数据到文件中
    private static FileWriter fw=null;
    private static BufferedWriter bw=null;
    private static String recoderFile="D:\\myRecoder.txt";

    //当游戏退出时，我们将allEnemyTankNum保存在文件中
    public static void keepRecoder() throws IOException {
        BufferedWriter bw = new BufferedWriter(new FileWriter(recoderFile));
        bw.write(allEnemyTankNum+"");//转换成字符串，写入文件
        bw.newLine();//换行
        bw.close();
    }
    public static int getAllEnemyTankNum() {
        return allEnemyTankNum;
    }

    public static void setAllEnemyTankNum(int allEnemyTankNum) {
        Recoder.allEnemyTankNum = allEnemyTankNum;
    }

    //当我方坦克击毁敌方坦克时，就应当allEnemyTankNum++
    public static void addallEnemyTankNum(){
        Recoder.allEnemyTankNum++;
    }
}
